package day09API.stringBuilder;

public class RegularDemo {
    public static void main(String[] args) {

        String str = "你好";
        System.out.println(str.matches("你[好们]"));
        String str1 = "你是";
        System.out.println(str1.matches("你[好们]"));


        String time = "2021 08 24";
        System.out.println(time.matches("\\d{4}\\s\\d{2}\\s\\d{2}"));


        String name = "DaiBenXiong";
        System.out.println(name.matches("\\w{8,20}"));

        String file = "demo.jpg";
        if (file.matches(".+\\.jpg")) {
            System.out.println("这是jpg文件");
        }else {
            System.out.println("不是jpg文件");
        }

//        判断邮箱地址是否合法
        String email = "2625816922@qq.com";
        if (email.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$")) {
            System.out.println("是邮箱");
        }else {
            System.out.println("不是邮箱");
        }

        String str2 = "老王,吃,喝,嫖,赌";
        String[] data ;
        data = str2.split(",");
        for (int i = 0; i < data.length; i++) {
            System.out.println(data[i]+"???");
        }
        System.out.println(str2.replaceAll("\\,", "爱"));

    }
}
